import React, { useEffect } from 'react'
import { NavBar } from 'antd-mobile'
import { useNavigate, useLocation, useParams } from 'react-router-dom'
import '../css/order.scss'
import queryString from 'query-string'
import { getSuccess } from '../../../request/instance'

export default function orderSuccess() {
  const navigate = useNavigate()
  const location = useLocation()
  const { id } = useParams()
  const search = queryString.parse(location.search)
  if (search) {
    search.id = id
  }
  console.log(search);


  const getSuccessData = async () => {
    let res = await getSuccess(search)
    console.log(res);
  }

  useEffect(() => {
    getSuccessData()
  }, [])





  return (
    <div className='orderSuccess'>
      <div className="iconSuccess">
        <span className='iconfont icon-Success'></span>
        <p>充值成功</p>
      </div>
      <div className="order">
        <p><span>订单号:</span><span>{search.out_trade_no}</span></p>
        <p><span>支付UID:</span><span>{search.seller_id}</span></p>
        <p><span>充值时间:</span><span>{search.timestamp}</span></p>
        <p><span>充值金额:</span><span>{search.total_amount}元</span></p>
      </div>
      <div className="button">
        <button onClick={() => navigate(`/wallet/${id}`)}>确定</button>
      </div>
    </div>
  )
}
